<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>深度克隆</title>
</head>
<body>
<script>
function deepCopy (obj) {
	var result = {};
	if(typeof obj == 'object') {
		for(let key in obj) {
			if(typeof obj[key] == 'object') {
				result[key] = deepCopy(obj[key]);
			}else {
				result[key] = obj[key];
			}
		}
	}else {
		return obj;
	}

	return result;
}
const obj1 = {
	a: 1,
	b: {
		x: 11,
		y: 22,
		c: {
			qq: 111
		}
	},
	add: function() {
		console.log(11);
	}
}
const obj2 = deepCopy(obj1);
console.log(obj2);
</script>
</body>
</html>